home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / dev / c / minigl.lha / MiniGL / demos / driverinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-26  |  4.3 KB  |  256 lines

  1. /*
  2. **  Simple driver-spec listing for MiniGL/Warp3D
  3. **  Author: Christian Michael 21 01 2002
  4. */
  5.  
  6. /* 02-04-02:
  7. ** Surgeon: added proper driverlist-scan for active drivers 
  8. */
  9.  
  10.  
  11. #include <mgl/gl.h>
  12.  
  13. #include <Warp3D/Warp3D.h>
  14. #ifdef __VBCC__
  15.     #include <proto/warp3d.h>
  16. #else
  17.     #ifdef __GNUC__
  18.         #ifdef __PPC__
  19.         #include <Warp3D/Warp3D_protos.h>
  20.         #else
  21.         #include <inline/Warp3D.h>
  22.         #endif
  23.     #elif defined(__STORM__)
  24.         #include <clib/Warp3D_protos.h>
  25.     #endif
  26. #endif
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29.  
  30. //Should contain all texformats supported by W3D
  31.  
  32. int TexFmt_Array[] = {
  33.     W3D_CHUNKY,
  34.     W3D_A8,
  35.     W3D_L8,
  36.     W3D_I8,
  37.     W3D_L8A8,
  38.     W3D_R5G6B5,
  39.     W3D_A1R5G5B5,
  40.     W3D_A4R4G4B4,
  41.     W3D_R8G8B8,
  42.     W3D_R8G8B8A8,
  43.     W3D_A8R8G8B8,
  44.     -999,
  45. };
  46.  
  47. char TexFmt_Str [][32] = {
  48.     {"W3D_CHUNKY"},
  49.     {"W3D_A8"},
  50.     {"W3D_L8"},
  51.     {"W3D_I8"},
  52.     {"W3D_L8A8"},
  53.     {"W3D_R5G6B5"},
  54.     {"W3D_A1R5G5B5"},
  55.     {"W3D_A4R4G4B4"},
  56.     {"W3D_R8G8B8"},
  57.     {"W3D_R8G8B8A8"},
  58.     {"W3D_A8R8G8B8"},
  59. };
  60.  
  61. //Expand this :)
  62.  
  63. int Supported_Array[] = {
  64.     W3D_Q_DRAW_POINT,
  65.     W3D_Q_DRAW_LINE,
  66.     W3D_Q_DRAW_TRIANGLE,
  67.     W3D_Q_CULLFACE,
  68.     W3D_Q_GOURAUDSHADING,
  69.     W3D_Q_SPECULAR,
  70.     W3D_Q_ONE_ONE,
  71.     W3D_Q_CHROMATEST,
  72.     W3D_Q_STENCILBUFFER,
  73.     W3D_Q_FOGGING,
  74.     W3D_Q_ANTIALIASING,
  75.     W3D_Q_TEXMAPPING3D,
  76.     W3D_Q_RECTTEXTURES,
  77.     W3D_Q_PERSPECTIVE,
  78.     W3D_Q_BILINEARFILTER,
  79.     W3D_Q_MMFILTER,
  80.     -999,
  81. };
  82.  
  83. char Supported_Str [][64] = {
  84.     {"POINT DRAWING                 "},
  85.     {"LINE DRAWING                  "},
  86.     {"TRIANGLE DRAWING              "},
  87.     {"BACKFACE CULLING              "},
  88.     {"GOURAUDSHADING                "},
  89.     {"SPECULAR HILIGHTS             "},
  90.     {"ADDITIVE BLENDING (ONE, ONE)  "},
  91.     {"CHROMA TEST                   "},
  92.     {"STENCILBUFFER                 "},
  93.     {"FOGGING                       "},
  94.     {"ANTIALIASING                  "},
  95.     {"VOLUMETRIC TEXTURES           "},
  96.     {"RECTANGULAR TEXTURES          "},
  97.     {"PERSPECTIVE CORRECT TEXMAPPING"},
  98.     {"BILINEAR FILTERING            "},
  99.     {"MIPMAP FILTERING              "},
  100. };
  101.  
  102.  
  103. char Res_Supported_Str [][32] = {
  104.     {"dummy"},
  105.     {"dummy"},
  106.     {"dummy"},
  107.     {"FULLY SUPPORTED"},
  108.     {"PARTIALLY SUPPORTED"},
  109.     {"UNSUPPORTED"},
  110. };
  111.  
  112.  
  113. GLboolean Query_TexFmt(W3D_Driver *driver, ULONG mask, GLboolean fullsupport)
  114. {
  115.     ULONG info, destfmt;
  116.  
  117.     destfmt = mini_CurrentContext->w3dContext->format;
  118.  
  119.     info = W3D_GetDriverTexFmtInfo(driver, mask, destfmt);
  120.  
  121.     if(fullsupport)
  122.     {
  123.         if(info & W3D_TEXFMT_FAST)
  124.           return GL_TRUE;
  125.       else
  126.           return GL_FALSE;
  127.     }
  128.     else
  129.     {
  130.     if(info & W3D_TEXFMT_UNSUPPORTED)
  131.         return GL_TRUE;
  132.     else
  133.         return GL_FALSE;
  134.     }
  135. }
  136.  
  137. int Query_Supported (W3D_Driver *driver, ULONG query)
  138. {
  139.     ULONG destfmt;
  140.     destfmt = mini_CurrentContext->w3dContext->format;
  141.  
  142.     return (int)W3D_QueryDriver(driver, query, destfmt);
  143. }
  144.  
  145. int main ()
  146. {
  147.     char *name;
  148.     W3D_Driver **driver;
  149.     int i,k;
  150.  
  151.     MGLInit();
  152.  
  153.     mglChoosePixelDepth(16);
  154.     mglChooseWindowMode(GL_TRUE);
  155.     mglCreateContext(0,0,320,240);
  156.  
  157.     driver = W3D_GetDrivers();
  158.  
  159.     while (1)
  160.     {
  161.  
  162.     if(*driver == NULL)
  163.         break;
  164.  
  165.     k = Query_Supported(driver[0], W3D_Q_MAXTEXWIDTH);
  166.  
  167.     if (k < 128) //skip inactive drivers
  168.     {
  169.         driver++;
  170.         continue;
  171.     }
  172.  
  173.     name = driver[0]->name;
  174.       printf("\n\n%s - Warp3D/MiniGL driver specs:\n", name);
  175.  
  176.       printf("\n");
  177.  
  178.     i=0;
  179.  
  180.     while (1)
  181.     {
  182.       if(Supported_Array[i] == -999)
  183.         break;
  184.  
  185.         k = Query_Supported(driver[0], (ULONG)Supported_Array[i]);
  186.  
  187.       printf("- %s %s\n", &Supported_Str[i][0], &Res_Supported_Str[k][0]);
  188.  
  189.     i++;
  190.     }
  191.  
  192.       printf("\n");
  193.  
  194.     //get max texture dimensions:
  195.  
  196.     k = Query_Supported(driver[0], W3D_Q_MAXTEXWIDTH);
  197.  
  198.     if (k)
  199.     {
  200.     printf("- MAX texture dimensions: %i x %i\n", k, Query_Supported(driver[0], W3D_Q_MAXTEXHEIGHT));
  201.     }
  202.  
  203.       printf("\n");
  204.  
  205.       printf("- Texture formats directly supported in HW:\n\n");
  206.  
  207.     i=0;
  208.  
  209.     while (1)
  210.     {
  211.       if(TexFmt_Array[i] == -999)
  212.         break;
  213.  
  214.         if(Query_TexFmt(driver[0], (ULONG)TexFmt_Array[i], GL_TRUE))
  215.           printf("  %s\n", &TexFmt_Str[i][0]);
  216.     i++;
  217.     }
  218.  
  219.       printf("\n");
  220.  
  221.       printf("- Totally incompatible texture formats:");
  222.  
  223.     i=0;
  224.     k=0;
  225.  
  226.     while (1)
  227.     {
  228.       if(TexFmt_Array[i] == -999)
  229.         break;
  230.  
  231.         if(Query_TexFmt(driver[0], (ULONG)TexFmt_Array[i], GL_FALSE))
  232.       {
  233.           printf("\n  %s", &TexFmt_Str[i][0]);
  234.         k++;
  235.       }
  236.     i++;
  237.     }
  238.  
  239.     if (k == 0)
  240.         printf("  NONE\n");
  241.  
  242.       printf("\n");
  243.  
  244.       printf("- MiniGL Extensions:\n\n  %s\n", glGetString(GL_EXTENSIONS));
  245.  
  246.       printf("\n\n");
  247.  
  248.    driver++;
  249.    }
  250.  
  251.     mglDeleteContext();
  252.     MGLTerm();
  253.  
  254.     return 0;
  255. }
  256.